//
//  BCUserInfoView.m
//  BangcaiBuy
//
//  Created by lsy on 16/6/15.
//  Copyright © 2016年 BCB. All rights reserved.
//

#import "BCUserInfoView.h"
#import "BCUserInfoCell.h"
#import "BCUserInfoCell1.h"

@interface BCUserInfoView ()
{
    UILabel *headName ;
    UIImageView *userImg;

}
@end

@implementation BCUserInfoView
- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self createView];
    }
    return self;
}

- (void)createView

{
    self.InfoList = @[@"店铺名称", @"店铺类型", @"联系人", @"联系电话", @"所在地区", @"详细地址"];
    self.placeHolderList = @[@"大连渝臻老重庆牛肚火锅", @"火锅", @"杜先生", @"13942664213", @"辽宁 - 大连", @"辽宁省大连市沙河口区"];
    self.table = [[UITableView alloc] initWithFrame:self.frame style:UITableViewStylePlain];
    [self addSubview:self.table];
    self.headView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 80)];
    headName = [[UILabel alloc] init];
    userImg = [[UIImageView alloc] init];
    [self.headView addSubview:headName];
    [self.headView addSubview:userImg];
    
    userImg.image = self.userImage ?:[UIImage imageNamed:@"头像"];
    
    headName.text = @"头像";
    headName.textColor = [UIColor colorWithRed:0.227  green:0.227  blue:0.227 alpha:1];
    headName.font = [UIFont systemFontOfSize:16];
    
    userImg.layer.cornerRadius = 20 ;
    userImg.layer.masksToBounds = YES;
    
    
    [headName mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(12);
        make.centerY.mas_equalTo(0);
        make.width.mas_equalTo(100);
        
    }];
    [userImg mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_equalTo(-12);
        make.centerY.mas_equalTo(0);
        make.width.and.height.mas_equalTo(40);
        
    }];
    
    self.table.tableHeaderView = self.headView;
    self.table.delegate = self;
    self.table.dataSource = self;
    [self.table registerClass:[BCUserInfoCell class] forCellReuseIdentifier:@"reuse"];
    [self.table registerClass:[BCUserInfoCell1 class] forCellReuseIdentifier:@"reuse1"];
    self.table.rowHeight = 60;
    self.table.separatorStyle = UITableViewCellSeparatorStyleNone;
    self.table.allowsSelection = NO;
   
 
}

- (void)setUserImage:(UIImage *)userImage
{
    _userImage = userImage;
    userImg.image = _userImage;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return self.InfoList.count;
}

- (UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    
    if ((indexPath.row == 0) || (indexPath.row == 2) || (indexPath.row == 3)) {
        BCUserInfoCell *cell = [tableView dequeueReusableCellWithIdentifier:@"reuse"];
        cell.infoName = self.InfoList[indexPath.row];
        cell.placeholder = self.placeHolderList[indexPath.row];
         return cell;
    }else{
        BCUserInfoCell1 *cell = [tableView dequeueReusableCellWithIdentifier:@"reuse1"];
        cell.infoName = self.InfoList[indexPath.row];
        cell.placeholder = self.placeHolderList[indexPath.row];

        return cell;
    }
    
    
}


/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
